package SquareFighters.Attack;

import SquareFighters.Actor;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;

/**
 *
 * @author Someperson1
 */
public class Magic {

    public int frame;
    int x, y;
    int dir;
    int l, w;
    public boolean uber;
    Actor actor;
    public Rectangle bounds;

    public Magic(int x, int y, int dir, Actor actor) {
        this.x = x;
        this.y = y;
        this.dir = dir;
        this.actor = actor;
        if ((int) (Math.random() * 20) == 0) {
            uber = true;
        }
        bounds = new Rectangle();
    }

    public void draw(Graphics g) {
        if (uber) {
            g.setColor(Color.RED);
            actor.modMagic(5);
        } else {
            g.setColor(Color.BLUE);
        }
        switch (dir) {
            case 0:
                y -= 20;
                l = 6;
                w = 30;
                break;
            case 1:
                x += 20;
                l = 30;
                w = 6;
                break;
            case 2:
                y += 20;
                l = 6;
                w = 30;
                break;
            case 3:
                x -= 20;
                l = 30;
                w = 6;
                break;
        }
        frame++;
        bounds.setBounds(x - 1 / 2, y - w / 2, l, w);
        g.fillRect(x - l / 2, y - w / 2, l, w);
    }
}
